package com.neuedu.his.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.neuedu.his.po.Medicalrecord;
import com.neuedu.his.service.MedicalrecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/medicalrecord")
public class MedicalRecordController {

    @Autowired
    MedicalrecordService service;
    @RequestMapping("/getbycasenumber")
    public List<Medicalrecord> getbycasenumber(@RequestParam Integer id){
        QueryWrapper<Medicalrecord> qw=new QueryWrapper<>();
        qw.eq("casenumber",id).in("casestate",2,1).orderByDesc("casestate");
        List<Medicalrecord> medicalrecords=service.list(qw);
        return medicalrecords;
    }

    @RequestMapping("/add")
    public Boolean add(@RequestBody Medicalrecord r){
        return service.saveOrUpdate(r);
    }
}